<template>
  <el-pagination
    class="sd-pagin flex-row"
    @size-change="handleSizeChange"
    @current-change="handleCurrentChange"
    background
    :current-page="pageNumber"
    :page-sizes="sizes"
    :page-size="pageSize"
    :layout="layout.join(',')"
    :total="total"
  ></el-pagination>
</template>

<script>
export default {
  props: {
    page: {
      type: Number,
      default: 1
    },
    size: {
      type: Number,
      default: 15
    },
    total: {
      type: Number,
      default: 0
    },
    layout: {
      type: Array,
      default: () => ["total", "sizes", "prev", "pager", "next", "jumper"]
    }
  },
  data() {
    return {
      sizes: [15, 30, 50, 100],
      // pageSize: this.size,
      // pageNumber: this.page
    };
  },
  computed: {
    pageSize() {
      return this.size
    },
    pageNumber() {
      return this.page
    }
  },
  methods: {
    // 当显示条数发生变化
    handleSizeChange(size) {
      this.$emit("size-change", size);
    },
    // 当显示页数发生变化
    handleCurrentChange(page) {
      this.$emit("page-change", page);
    }
  }
};
</script>
<style scoped lang="scss">
</style> 